package com.example.personalizededucationsystem.dto.dto;

import com.example.personalizededucationsystem.model.StudentAssignment;
import lombok.Getter;
import lombok.Setter;

import java.time.Instant;

@Setter
@Getter
public class AssignmentSubmissionSummaryDto {
    private Long studentAssignmentId;
    private Long studentId;
    private String studentName;
    private StudentAssignment.Status status;
    private Instant submissionDate;
    private Float score;

    public static AssignmentSubmissionSummaryDto fromEntity(StudentAssignment sa) {
        AssignmentSubmissionSummaryDto dto = new AssignmentSubmissionSummaryDto();
        dto.setStudentAssignmentId(sa.getId());
        dto.setStatus(sa.getStatus());
        dto.setSubmissionDate(sa.getSubmissionDate());
        dto.setScore(sa.getScore());

        if (sa.getStudent() != null) {
            dto.setStudentId(sa.getStudent().getUserId());
            dto.setStudentName(sa.getStudent().getNickname());
        }
        return dto;
    }

}
